package main

import (
	"fmt"
	"runtime"
	"sync"
)

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	//c:=make(chan bool, 9)
	//for i:=1;i<10;i++{
	//	go Go(c,i)
	//}
	//<-c

	wg:=sync.WaitGroup{}
	wg.Add(9)
	for i:=1;i<10;i++{
		go Go2(&wg,i)
	}
	wg.Wait()
}

func Go2(wg *sync.WaitGroup, index int )  {
	a:=1
	for i:=0;i<4000000;i++{
		a++
	}
	fmt.Println(index,a)
	wg.Done()
}

//func Go(c chan bool, index int){
//	a:=1
//	for i:=0;i<4000000;i++{
//		a++
//	}
//	fmt.Println(index,a)
//	c<-true
//}